package com.zijin.config;

import com.zijin.properties.SnowflakeIdProperties;
import com.zijin.utils.SnowflakeIdGeneratorUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Title: SnowflakeIdGeneratorConfig
 * @Author JWei Xu
 * @Package com.zijin.config
 * @Date 2024/12/7 12:16
 * @description: 雪花ID生成工具类的配置
 */
@Configuration
public class SnowflakeIdGeneratorConfig {

    @Bean
    public SnowflakeIdGeneratorUtil snowflakeIdGeneratorUtil(SnowflakeIdProperties snowflakeIdProperties){
        return new SnowflakeIdGeneratorUtil(snowflakeIdProperties.getWorkerId(),snowflakeIdProperties.getDatacenterId());
    }
}
